package nl.changer.audiowifedemo_ohos.slice;

import ohos.agp.components.DirectionalLayout;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;

public class ToastHelper {
    private static ToastDialog toastDialog;

    public static ToastHelper init(Context context) {
        toastDialog = new ToastDialog(context);
        toastDialog.setSize(DirectionalLayout.LayoutConfig.MATCH_CONTENT,
                DirectionalLayout.LayoutConfig.MATCH_CONTENT);
        return new ToastHelper();
    }

    public ToastHelper setMessage(String msg) {
        toastDialog.setText(msg);
        return this;
    }

    public ToastHelper setDuration(int time) {
        toastDialog.setDuration(time);
        return this;
    }

    public void show() {
        toastDialog.show();
    }
}
